﻿
Type.registerNamespace('Merbla.WebForms.AjaxControls');

Merbla.WebForms.AjaxControls.ItemControl = function(element) {

    //local variables
this._parameterName = '';
this._parameterValue = '';


this._clickHandler = null; 
    
    Merbla.WebForms.AjaxControls.ItemControl.initializeBase(this, [element]);


}

Merbla.WebForms.AjaxControls.ItemControl.prototype =
{

    get_parameterName: function() {
        return this._parameterName;
    },

    set_parameterName: function(value) {
        var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);
        if (e) throw e;

        if (this._parameterName != value) {
            // Only sets the value if it differs from the current
            this._parameterName = value;
            //Raise the propertyChanged event
            this.raisePropertyChanged('parameterName'); //This is a base class method which resides in Sys.Component
        }
    },
    get_parameterValue: function() {
        return this._parameterValue;
    },

    set_parameterValue: function(value) {
        var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);
        if (e) throw e;

        if (this._parameterValue != value) {
            // Only sets the value if it differs from the current
            this._parameterValue = value;
            //Raise the propertyChanged event
            this.raisePropertyChanged('parameterValue'); //This is a base class method which resides in Sys.Component
        }
    },


    initialize: function() {

        this._clickHandler = Function.createDelegate(this, this._onClick) 

        var target = this.get_element();

        //Attach the required event handlers
        $addHandlers(target, { 'click': this._clickHandler }, this); 

        Merbla.WebForms.AjaxControls.ItemControl.callBaseMethod(this, 'initialize');
    },

    dispose: function() {
        $clearHandlers(this.get_element()); // Detach all event handlers
        delete this._clickHandler;

        Merbla.WebForms.AjaxControls.ItemControl.callBaseMethod(this, 'dispose');
    }
    ,
    add_click: function(handler) {
        this.get_events().addHandler('click', handler);
    },

    remove_click: function(handler) {
        this.get_events().removeHandler('click', handler);
    },

   

    _onClick: function(e) {
        e.preventDefault();

        var handler = this.get_events().getHandler('click');

        if (handler != null) {
            handler(this, Sys.EventArgs.Empty);
        }
    }
    
      
}

Merbla.WebForms.AjaxControls.ItemControl.registerClass('Merbla.WebForms.AjaxControls.ItemControl', Sys.UI.Control);

if (typeof (Sys) != 'undefined') {
    Sys.Application.notifyScriptLoaded();
}


 
